import React from 'react'
import { Switch, Route, Redirect } from "react-router-dom"
import AnimatedSwitch from './AnimatedSwitch.js'
export default function View(props) {
    return (
        <AnimatedSwitch>
            {
                props.routes.map((item, index) => {
                    if (item.from) {
                        return <Redirect key={index} from={item.from} to={item.to} exact />
                    }
                    if (!item.from && item.to) {
                        return <Redirect key={index} to={item.to} exact />
                    }
                    return <Route key={index} path={item.path} component={item.component}></Route>
                })
            }
        </AnimatedSwitch>
    )
}
